/*
 * ZhaoBiaoGGSaxParseHtml.java
 * 招标公告的Html转换
 * 牟瑞
 * 2012-08-28
 */
package cn.com.truelore.parser;

import org.apache.commons.lang.StringUtils;
import org.ccil.cowan.tagsoup.Parser;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

public class ZhaoBiaoGGDetailSaxParseHtml extends Parser {

	/*
	 * 详细内容
	 */
	private StringBuffer detailContext;
	boolean flgDetail = false;
	boolean flgDetialTd = false;

	// 调用多次 开始解析
	@Override
	public void startElement(String uri, String localName, String qName,
			Attributes attributes) throws SAXException {
		if ("tr".equals(qName) == true) {
			String strTrId = attributes.getValue("id");
			if (StringUtils.isBlank(strTrId) == false) {
				if ("ZBGGDetail1_trZs".equals(strTrId) == true
						|| "ZBGGDetail1_trZdy".equals(strTrId) == true) {
					flgDetail = true;
				}
			}
		}
		if (flgDetail == true && "td".equals(qName) == true) {
			detailContext = new StringBuffer();
			flgDetialTd = true;
			flgDetail = false;
		}

	}

	// 调用多次
	@Override
	public void characters(char[] ch, int start, int length)
			throws SAXException {
		if (flgDetialTd == true) {
			detailContext.append(new String(ch, start, length));
		}
	}

	public String getDetailContext() {
		return detailContext.toString();
	}

}
